import axios from '@/utils/request'
import type { ILogin, IInfo } from './types/login'

export function login (data:any) {
  return axios<ILogin>({
    url: import.meta.env.VITE_BASEURL_IDENTITY_SERVER + '/connect/token',
    method: 'post',
    headers: { 'content-type': 'application/x-www-form-urlencoded' },
    data: new URLSearchParams(data)
  },
  {
    errorMessage: false
  })
}
export function logout () {
  return axios({
    url: import.meta.env.VITE_BASEURL_IDENTITY_SERVER + '/api/account/logout',
    method: 'get'
  })
}

export function getInfo () {
  return axios<IInfo>({
    url: import.meta.env.VITE_BASEURL_IDENTITY_SERVER + '/api/account/my-profile',
    method: 'get'
  })
}
